package com.wilmer.paperAnswers.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wilmer.common.annotation.Log;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.common.enums.BusinessType;
import com.wilmer.paperAnswers.domain.YwPaperStudentAnswers;
import com.wilmer.paperAnswers.service.IYwPaperStudentAnswersService;
import com.wilmer.common.utils.poi.ExcelUtil;
import com.wilmer.common.core.page.TableDataInfo;

/**
 * 答题记录Controller
 * 
 * @author zl
 * @date 2024-04-23
 */
@RestController
@RequestMapping("/paperAnswers/paperAnswers")
public class YwPaperStudentAnswersController extends BaseController
{
    @Autowired
    private IYwPaperStudentAnswersService ywPaperStudentAnswersService;


    @PostMapping({"/awardingOfPoints"})
    public AjaxResult awardingOfPoints(@RequestBody YwPaperStudentAnswers ywPaperStudentAnswers) {
        return this.toAjax(this.ywPaperStudentAnswersService.awardingOfPoints(ywPaperStudentAnswers));
    }

    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:list')")
    @GetMapping({"/list"})
    public TableDataInfo list(YwPaperStudentAnswers ywPaperStudentAnswers) {
        this.startPage();
        List<YwPaperStudentAnswers> list = this.ywPaperStudentAnswersService.selectYwPaperStudentAnswersList(ywPaperStudentAnswers);
        return this.getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:export')")
    @Log(
            title = "答题记录",
            businessType = BusinessType.EXPORT
    )
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, YwPaperStudentAnswers ywPaperStudentAnswers) {
        List<YwPaperStudentAnswers> list = this.ywPaperStudentAnswersService.selectYwPaperStudentAnswersList(ywPaperStudentAnswers);
        ExcelUtil<YwPaperStudentAnswers> util = new ExcelUtil(YwPaperStudentAnswers.class);
        util.exportExcel(response, list, "答题记录数据");
    }

    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:query')")
    @GetMapping({"/{answerId}"})
    public AjaxResult getInfo(@PathVariable("answerId") Long answerId) {
        return this.success(this.ywPaperStudentAnswersService.selectYwPaperStudentAnswersByAnswerId(answerId));
    }

    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:add')")
    @Log(
            title = "答题记录",
            businessType = BusinessType.INSERT
    )
    @PostMapping
    public AjaxResult add(@RequestBody YwPaperStudentAnswers ywPaperStudentAnswers) {
        return this.toAjax(this.ywPaperStudentAnswersService.insertYwPaperStudentAnswers(ywPaperStudentAnswers));
    }

    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:edit')")
    @Log(
            title = "答题记录",
            businessType = BusinessType.UPDATE
    )
    @PutMapping
    public AjaxResult edit(@RequestBody YwPaperStudentAnswers ywPaperStudentAnswers) {
        return this.toAjax(this.ywPaperStudentAnswersService.updateYwPaperStudentAnswers(ywPaperStudentAnswers));
    }

    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:remove')")
    @Log(
            title = "答题记录",
            businessType = BusinessType.DELETE
    )
    @DeleteMapping({"/{answerIds}"})
    public AjaxResult remove(@PathVariable Long[] answerIds) {
        return this.toAjax(this.ywPaperStudentAnswersService.deleteYwPaperStudentAnswersByAnswerIds(answerIds));
    }
//    /**
//     * 查询答题记录列表
//     */
//    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(YwPaperStudentAnswers ywPaperStudentAnswers)
//    {
//        startPage();
//        List<YwPaperStudentAnswers> list = ywPaperStudentAnswersService.selectYwPaperStudentAnswersList(ywPaperStudentAnswers);
//        return getDataTable(list);
//    }
//
//    /**
//     * 导出答题记录列表
//     */
//    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:export')")
//    @Log(title = "答题记录", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, YwPaperStudentAnswers ywPaperStudentAnswers)
//    {
//        List<YwPaperStudentAnswers> list = ywPaperStudentAnswersService.selectYwPaperStudentAnswersList(ywPaperStudentAnswers);
//        ExcelUtil<YwPaperStudentAnswers> util = new ExcelUtil<YwPaperStudentAnswers>(YwPaperStudentAnswers.class);
//        util.exportExcel(response, list, "答题记录数据");
//    }
//
//    /**
//     * 获取答题记录详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:query')")
//    @GetMapping(value = "/{answerId}")
//    public AjaxResult getInfo(@PathVariable("answerId") Long answerId)
//    {
//        return success(ywPaperStudentAnswersService.selectYwPaperStudentAnswersByAnswerId(answerId));
//    }
//
//    /**
//     * 新增答题记录
//     */
//    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:add')")
//    @Log(title = "答题记录", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody YwPaperStudentAnswers ywPaperStudentAnswers)
//    {
//        return toAjax(ywPaperStudentAnswersService.insertYwPaperStudentAnswers(ywPaperStudentAnswers));
//    }
//
//    /**
//     * 修改答题记录
//     */
//    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:edit')")
//    @Log(title = "答题记录", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody YwPaperStudentAnswers ywPaperStudentAnswers)
//    {
//        return toAjax(ywPaperStudentAnswersService.updateYwPaperStudentAnswers(ywPaperStudentAnswers));
//    }
//
//    /**
//     * 删除答题记录
//     */
//    @PreAuthorize("@ss.hasPermi('paperAnswers:paperAnswers:remove')")
//    @Log(title = "答题记录", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{answerIds}")
//    public AjaxResult remove(@PathVariable Long[] answerIds)
//    {
//        return toAjax(ywPaperStudentAnswersService.deleteYwPaperStudentAnswersByAnswerIds(answerIds));
//    }
}
